home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / faq / vol15n14.zip / DDGAME.ZIP / SPACEFRA.H < prev    next >
C/C++ Source or Header  |  1996-04-17  |  3KB  |  121 lines

  1. // SpaceFrame.h : header file
  2. //
  3.  
  4. #include "GameFrame.h"
  5.  
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CSpaceFrame frame
  8.  
  9. class CAnim;
  10.  
  11. enum SpriteType
  12. {
  13.   typeShip,
  14.   typeEnemy,
  15.   typeBullet
  16. };
  17.  
  18. typedef struct _SPRITE
  19. {
  20.     struct  _SPRITE* pNext;         
  21.     struct  _SPRITE* pPrev;         
  22.     SpriteType       eType;         
  23.     double           dPosX, dPosY;  
  24.     double           dVelX, dVelY;  
  25.     int              nDirection;
  26.     int              nFrame;  
  27.     int              nDelay;
  28.     CAnim*           pAnim;
  29. } SPRITE;
  30.  
  31. const int NUM_DIRECTIONS = 32;
  32. const int WORLD_MIN_X = 0;
  33. const int WORLD_MIN_Y = 0;
  34. const int WORLD_MAX_X = 640;
  35. const int WORLD_MAX_Y = 480;
  36. const int ANIM_DELAY = 5;
  37. const int TURN_DELAY = 0;
  38.  
  39. class CSpaceFrame : public CGameFrame
  40. {
  41. public:
  42.     CSpaceFrame();           // protected constructor used by dynamic creation
  43.     virtual ~CSpaceFrame();
  44.  
  45. // Operations
  46. public:
  47.     virtual BOOL InitGraphics();
  48.   virtual void KillGraphics();
  49.  
  50.     virtual BOOL UpdateGame();
  51.  
  52. protected:
  53.   void MoveSprites();
  54.   void CollideSprites();
  55.   void DrawSprites();
  56.  
  57.   SPRITE* AddSprite(SpriteType eType,
  58.                     double dX = 0.0,
  59.                     double dY = 0.0);
  60.  
  61.   void RemoveSprite(SPRITE* pSprite);
  62.  
  63.   BOOL InitLevel(int nDifficulty = 0);
  64.   void KillLevel();
  65.  
  66.   void DisplayMessage(char* pStr);
  67.   void DisplayLevel();
  68.  
  69.     virtual BOOL InitPalette();
  70.   virtual BOOL RestoreSurfaces();
  71.  
  72.   void DrawText();
  73.  
  74.   int RandVal( int low, int high );
  75.   double RandVal( double low, double high );
  76.  
  77. // Attributes
  78. protected:
  79.   // ddraw vars
  80.   LPDIRECTDRAWSURFACE m_pFrameRateSurface;
  81.   LPDIRECTDRAWSURFACE m_pTextSurface;
  82.   DDBLTFX m_ddbltfx;
  83.   DDSURFACEDESC m_ddsd;
  84.  
  85.   // anims
  86.   CAnim* m_pShipAnim;
  87.   CAnim* m_pBulletAnim;
  88.   CAnim* m_pEnemyAnim;
  89.  
  90.   // head node of sprite list
  91.   SPRITE m_head;
  92.  
  93.   // Variables used in frame rate calculations
  94.     CFont m_font;
  95.     DWORD m_dwStartTime;
  96.     int m_nFrameCount;
  97.   int m_nFrameRate;
  98.  
  99.   int m_nLives;
  100.   int m_nLevel;
  101.   int m_nTurnDelay;
  102.  
  103. // Overrides
  104. protected:
  105.   CString GetWindowTitle();
  106.  
  107. public:
  108.     // ClassWizard generated virtual function overrides
  109.     //{{AFX_VIRTUAL(CSpaceFrame)
  110.     //}}AFX_VIRTUAL
  111.  
  112. // Implementation
  113. protected:
  114.     // Generated message map functions
  115.     //{{AFX_MSG(CSpaceFrame)
  116.     //}}AFX_MSG
  117.     DECLARE_MESSAGE_MAP()
  118. };
  119.  
  120. /////////////////////////////////////////////////////////////////////////////
  121.